In computing, a temporary folder or temporary directory is a directory used to hold temporary files. Many operating systems and some software automatically delete the contents of this directory at bootup or at regular intervals.
For security reasons, it is best for each user to have their own temporary directory, since there has been a history of security vulnerabilities with temporary files due to programs incorrect file permissions or race conditions.
A standard procedure for system administration is to reduce the amount of storage space used (typically, on a disk drive) by removing temporary files. In multi-user systems, this can potentially remove active files, disrupting users' activities. To avoid this, some space-reclaiming procedures remove only files which are inactive or "old" - those which have not been read or modified in several days.
In MS-DOS and Microsoft Windows, the temporary directory is set by the environment variable TEMP. Originally, the default was c:\Temp, then %Windows%\Temp. In modern versions, the temporary directory is set per-user as Local Settings\Temp, although it is still user-relocatable.
In Unix and Linux, the global temporary directories are /tmp and /var/tmp. Web browsers periodically write data to the tmp directory during page views and downloads. Typically, /var/tmp is for persistent files (as it may be preserved over reboots), and /tmp is for more temporary files. See Filesystem Hierarchy Standard. In addition, a user can set their TMPDIR environment variable to point to a preferred directory (where the creation and modification of files is allowed).
In Unix, the /tmp directory will often be a separate disk partition. In systems with magnetic hard disk drives, performance (overall system IOPS) will increase if disk-head movements from regular disk I/O are separated from the access to the temporary directory. Increasingly, memory-based solutions for the temporary directory or folder are being used, such as "RAM disks" set up in random-access memory or the shared-memory device /dev/shm in Linux.
A Flash-based solid-state drive is less suitable as a temporary-storage device for reading and writing due to the asymmetric read/write duration and due to wear. (See wear leveling.)